package com.quick.threadtest;

public class ReentrantLockTestMain {
    public static void main(String[] args) throws Exception{
        ReentrantLockTest t = new ReentrantLockTest();
        ThreadPut threadPut = new ThreadPut(t);
        threadPut.start();
        ThreadTake threadTake = new ThreadTake(t);
        threadTake.start();
//        Thread.sleep(100L);
    }

}
class  ThreadPut extends Thread{
    private ReentrantLockTest t;
    public  ThreadPut(ReentrantLockTest t){
        this.t= t;
    }
    @Override
    public void run() {
        try {
            for (int i = 0; i < 100; i++) {
                t.put(i);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

class ThreadTake extends Thread{
    private ReentrantLockTest t;
    public  ThreadTake(ReentrantLockTest t){
        this.t= t;
    }
    @Override
    public void run() {
        try {
            for (int i = 0; i < 110; i++) {
                t.take();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
